package com.tipcp.equip.collect.service.strategy;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum  CollectStrategyTypeEnum {

    TEMPERATURE("temperature", new TemperatureReadStrategy()),

    PRESSURE("pressure",new PressureReadStrategy()),
    HUMIDITY("humidity",new HumidityReadStrategy()),
    VIBRATION("vibration",new VibrationReadStrategy());

    private final String type;
    private final ReadTCPStrategy strategy;

    CollectStrategyTypeEnum(String type, ReadTCPStrategy strategy) {
        this.type = type;
        this.strategy = strategy;
    }

    public static ReadTCPStrategy getStrategy(String type){
        for (CollectStrategyTypeEnum value : values()) {
            if (Objects.equals(value.getType(),type)){
                return value.getStrategy();
            }
        }
        return null;
    }

}
